<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
 
<form class="layui-form" id="vipInf"  style="margin: 40px 100px 10px 100px;">	
  <div class="layui-form-item">
    <label class="layui-form-label">会员类型:</label>
    <div class="layui-input-block">
      <input type="text" name="vlevel" lay-verify="" autocomplete="off" placeholder="" class="layui-input" style="width: 190px;">
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">会员折扣:</label>
      <div class="layui-input-inline">
        <input type="tel" name="vdiscount" lay-verify="" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button id="qwe" class="layui-btn" lay-submit="" lay-filter="demo1" style="background-color: #337AB7;color: white;">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
          
<script src="layui.js" charset="utf-8"></script>
<script src="layui/jquery.min.js"></script>
<!-- <script>
$("#qwe").click(function(){
	$.ajax({
		url:"/management/insertVip",
		type:"post",
		data:$("#vipInf").serialize(),
		success:function(data){
			alert(data);
			location.reload();
		}
	})
})
</script> -->
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  
  
  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo_editor');
  
  //监听提交
  form.on('submit(demo1)', function(data){
	  $.ajax({
			url:"/management/insertVip",
			type:"post",
			async: false,
			data:$("#vipInf").serialize(),
			success:function(data){
				if(data=="新增成功"){
					alert(data);
					var index = parent.layer.getFrameIndex(window.name);
    				parent.layer.close(index);		
				}else{
					alert(data);
				}
				location.reload();
			}
	})
  });
 
});
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->


</body>
</html>
